package com.gollum.system.domain.vo;

import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.gollum.system.api.domain.SysDept;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.List;
import java.util.stream.Collectors;

/**
 * ant design 下拉树实体
 *
 * @author Herther
 * @createTime 2022年12月31日 14:27:00
 * @since 1.0.0
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Setter
@Accessors(chain = true)
public class AntTreeSelect {


    private Long key;

    private String title;

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<AntTreeSelect> children;

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private String selectable;


    public AntTreeSelect(SysDept dept) {
        this.key = dept.getDeptId();
        this.title = dept.getDeptName();
        this.children = dept.getChildren().stream().map(AntTreeSelect::new).collect(Collectors.toList());
    }

}
